import { SpriteFrame, resources } from "cc";
import Singleton from "../../base/singleton"

export default class ResourceDir extends Singleton {
    // 单例模式
    static get Instance(): ResourceDir { return super.getInstance<ResourceDir>(); } // 调用全局单例

    loadDir(path: string, type: typeof SpriteFrame = SpriteFrame) {
        return new Promise<SpriteFrame[]>((resolve, reject) => {
            resources.loadDir(path, type, (err, assets) => {
                if (err) return reject(err);
                resolve(assets);
            });
        });
    }
};